package com.xz.courseschedule.controller;

import com.xz.courseschedule.entity.Classes;
import com.xz.courseschedule.service.ClassesService;
import com.xz.courseschedule.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 班级管理控制器
 * @Author: zys
 * @CreateTime: 2025-05-24
 */
@Tag(name = "班级管理", description = "班级信息的管理和查询")
@RestController
@RequestMapping("/classes")
public class ClassesController {

    @Autowired
    private ClassesService classesService;

    @Operation(summary = "获取班级列表", description = "获取系统中所有班级的信息列表")
    @GetMapping("/getList")
    public Result getList(){
        return classesService.getList();
    }

    @Operation(summary = "根据ID获取班级", description = "根据班级ID获取单个班级的详细信息")
    @Parameter(name = "id", description = "班级ID", required = true)
    @GetMapping("/get/{id}")
    public Result getById(@PathVariable Long id){
        return classesService.getById(id);
    }

    @Operation(summary = "新增班级", description = "添加新的班级到系统中")
    @PostMapping("/add")
    public Result add(@RequestBody Classes classes){
        return classesService.add(classes);
    }

    @Operation(summary = "更新班级", description = "更新指定的班级信息")
    @PutMapping("/update")
    public Result update(@RequestBody Classes classes){
        return classesService.update(classes);
    }

    @Operation(summary = "删除班级", description = "根据班级ID删除指定的班级")
    @Parameter(name = "id", description = "班级ID", required = true)
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return classesService.delete(id);
    }

    @Operation(summary = "批量删除班级", description = "根据班级ID列表批量删除班级")
    @DeleteMapping("/deleteBatch")
    public Result deleteBatch(@RequestBody Long[] ids){
        return classesService.deleteBatch(ids);
    }
}
